package com.albaba.designpattern.factory.text_004;

import com.albaba.designpattern.factory.text_004.factory.AppliancesFactory;
import com.albaba.designpattern.factory.text_004.factory.HisenseFactory;
import com.albaba.designpattern.factory.text_004.product.AbstractFreezer;
import com.albaba.designpattern.factory.text_004.product.AbstractTV;

/**
 * @Description: TODO
 * @Author zx
 * @Date 2025/2/19 16:05
 * @Version 1.0
 */
public class Client {

    private AbstractTV tv;

    private AbstractFreezer freezer;

    public Client(AppliancesFactory factory) {
        // 在客户端看来就是使用抽象工厂来生产家电
        this.tv = factory.createTV();
        this.freezer = factory.createFreezer();
    }

    public AbstractTV getTv() {
        return tv;
    }

    public void setTv(AbstractTV tv) {
        this.tv = tv;
    }

    public AbstractFreezer getFreezer() {
        return freezer;
    }

    public void setFreezer(AbstractFreezer freezer) {
        this.freezer = freezer;
    }

    @Override
    public String toString() {
        return "Client{" +
                "tv=" + tv +
                ", freezer=" + freezer +
                '}';
    }

    public static void main(String[] args) {
        Client client = new Client(new HisenseFactory());
        System.out.println(client);
    }
}
